"use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["packages_date-picker_components_DatePicker_tsx"],{337:(e,t,a)=>{a.d(t,{n:()=>d});var n=a(74848),r=a(96540),l=a(29295),o=a(29731),i=a(88431);let s={Popover:"ValidationErrorPopover-module__Popover--L6a2z",aboveCaret:"ValidationErrorPopover-module__aboveCaret--n7mG4",PopoverContent:"ValidationErrorPopover-module__PopoverContent--sE8qO",belowCaret:"ValidationErrorPopover-module__belowCaret--bwBKr"};var u=a(34164);let d=({id:e,message:t,testId:a,margin:d=4,position:c="below"})=>{let m=(0,r.useRef)(null),f=void 0!==t;return(0,i.N)(()=>{if(!f)return;let e=m.current;if(!e)return;let t=(e=>{let t=e.parentElement;for(;t;){let e=getComputedStyle(t);if("visible"!==e.overflow&&"static"!==e.position)return t;t=t.parentElement}return document.body})(e);e.style.maxWidth=`${t.clientWidth-2*d}px`,e.style.left="50%";let a=e.getBoundingClientRect(),n=t.getBoundingClientRect(),r=a.left-n.left,l=n.right-a.right,o=r{function n(e){return null===e||e instanceof Date}function r(e){return null===e||Array.isArray(e)}function l(e){return null===e||!!e.from}function o(e){return l(e)&&(null===e||null!==e.to)}a.d(t,{P0:()=>o,QJ:()=>l,le:()=>n,m:()=>r})},29731:(e,t,a)=>{a.d(t,{G:()=>n});let n=e=>({})},36289:(e,t,a)=>{a.d(t,{Bt:()=>p,Uq:()=>h,Wc:()=>c,iV:()=>d,qE:()=>f,vV:()=>m});var n=a(72880),r=a(89369),l=a(19684),o=a(7818),i=a(83223),s=a(4721),u=a(10867);let d=e=>new Date(new Date(e).toDateString()),c=e=>e instanceof Date?d(e):e&&(0,u.m)(e)?e.map(d):e&&(0,u.QJ)(e)?{from:d(e.from),to:e.to&&d(e.to)}:null,m=(e,t=null)=>{if(!e)return d(new Date);if(e instanceof Date)return d(e);if((0,u.m)(e)){let t=e.at(-1);return t?d(t):null}return(0,u.QJ)(e)?"to"===t&&e.to?d(e.to):d(e.from):null},f=(e,{minDate:t,maxDate:a})=>t&&(0,n.Y)(e,t)?t:a&&(0,r.d)(e,a)?a:e,p=(e,{minDate:t,maxDate:a})=>(!t||(0,r.d)(e,t))&&(!a||(0,n.Y)(e,a)),h=(e,t="auto")=>{if(!(0,l.c)(e))return e;switch(t){case"forward":return(0,o.u)(e);case"backward":return(0,i.N)(e);case"auto":return(0,s.X)(e)?(0,o.u)(e):(0,i.N)(e)}}},49453:(e,t,a)=>{a.d(t,{Yq:()=>f,_U:()=>m,eW:()=>c,gb:()=>p});var n=a(44660),r=a(96912),l=a(72471),o=a(90680),i=a(10867),s=a(36289);let u="MMM d",d="MMM d, yyyy",c=e=>"short"===e?u:"long"===e?d:e,m=(e,t=[])=>{let a=(0,s.iV)(new Date);for(let l of["PP","P",...t.map(c)]){let t=(0,n.qg)(e,l,a);if((0,r.f)(t))return(0,s.iV)(t)}return null},f=(e,t)=>{let a=(0,s.iV)(new Date);return t!==u&&t!==d?(0,l.GP)(e,t):t===u&&e.getUTCFullYear()!==a.getUTCFullYear()?(0,l.GP)(e,d):(0,l.GP)(e,t)},p=({selection:e,dateFormat:t,placeholder:a="Choose Date",rawFormat:n=!1,variant:r="single"})=>{if(!e)return n?"":a;let l="MMM d";switch(l=!n&&t?c(t):"MM/dd/yyyy",r){case"single":if(e instanceof Date)return f(e,l);if(Array.isArray(e)&&e?.[0]instanceof Date)return f(e[0],l);if((0,i.QJ)(e))return f(e.from,l);else return o.o.invalidSelection;case"multi":if(Array.isArray(e)){if(e.length>3&&!n)return`${e.length} Selected`;if(0===e.length&&!n)return a;return e.map(e=>f(e,l)).join(", ")}if(e instanceof Date)return[e].map(e=>f(e,l)).join(", ");if((0,i.QJ)(e))return[e.from,e.to].map(e=>e?f(e,l):"").join(", ");else return o.o.invalidSelection;case"range":if((0,i.QJ)(e))return Object.entries(e).map(([,e])=>e?f(e,l):"").join(" - ");if(e instanceof Date)return Object.entries({from:e,to:null}).map(([,e])=>e?f(e,l):"").join(" - ");if(Array.isArray(e))return Object.entries({from:e.at(0),to:e.at(1)}).map(([,e])=>e?f(e,l):"").join(" - ");else return o.o.invalidSelection;default:return o.o.invalidConfiguration}}},83463:(e,t,a)=>{a.r(t),a.d(t,{DatePicker:()=>eJ});var n,r=a(74848),l=a(96540),o=a(29731),i=a(38621),s=a(26108),u=a(21373),d=a(10095),c=a(21513),m=a(93330),f=a(49087),p=a(4883),h=a(93876),g=a(72880),y=a(89369),v=a(13999),b=a(42340),D=a(84583),x=a(10867),k=a(36289),C=a(93218),_=a(31422),j=a(40828),M=a(17764);let w=(e,t)=>t?(0,k.Uq)(e,"auto"):e,N=(e,t,a)=>a?(0,C.D)(e,t):(0,v.f)(e,t),I=(e,t,a)=>a?(0,_.E)(e,t):(0,j.e)(e,t),P=(e,{minDate:t,maxDate:a},n)=>{let r=t&&((e,t)=>t?(0,k.Uq)(e,"forward"):e)(t,n),l=a&&((e,t)=>t?(0,k.Uq)(e,"backward"):e)(a,n);return w((0,k.qE)(e,{minDate:r,maxDate:l}),n)},S=(e,t)=>{let[a,n]=((e,t)=>e.to&&(0,y.d)(e.from,e.to)?[{...e,from:e.to,to:e.from},"from"===t?"to":"from"]:[e,t])(e,t.adjustableRangeEnd??"to"),r={...t,adjustableRangeEnd:n};return((e,{disableWeekends:t=!1,...a})=>{if(!e.to)return{...e,from:P(e.from,a,t)};let n=(0,M.c)(e.to,e.from),r=P(e.to,a,t),l=P((0,j.e)(r,n),a,t),o=(0,v.f)(l,n);return{...e,from:l,to:o}})(((e,{disableWeekends:t=!1,adjustableRangeEnd:a="to",...n})=>{let r=w(e.from,t);if(!e.to)return{...e,from:r};let l=w(e.to,t);switch(a){case"from":return{...e,from:P(e.from,{minDate:((e,{maxRangeSize:t},a)=>void 0!==t?I(e,t-1,a):void 0)(l,n,t),maxDate:((e,{minRangeSize:t},a)=>void 0!==t?I(e,t-1,a):void 0)(l,n,t)},t),to:l};case"to":return{...e,from:r,to:P(e.to,{minDate:((e,{minRangeSize:t},a)=>void 0!==t?N(e,t-1,a):void 0)(r,n,t),maxDate:((e,{maxRangeSize:t},a)=>void 0!==t?N(e,t-1,a):void 0)(r,n,t)},t)}}})(a,r),r)},A=(e,t)=>(0,D.n)(e,t.from)?"from":t.to?(0,D.n)(e,t.to)?"to":(0,y.d)(e,t.from)&&(0,g.Y)(e,t.to)?"middle":null:null,E=(0,l.createContext)(null),R=()=>{let e=(0,l.useContext)(E);if(!e)throw Error("useDatePickerContext must be used inside a DatePickerProvider");return e},F=({children:e,anchor:t="button",anchorClassName:a,forwardedAnchorRef:n,confirmation:o=!1,confirmUnsavedClose:i=!1,compressedHeader:s=!1,dateFormat:u="short",disabled:d,disableWeekends:C=!1,fieldName:_="Date",iconPlacement:j="start",maxDate:M,minDate:w,showTodayButton:N=!0,showClearButton:I=!1,view:P="1-month",weekStartsOn:A="Sunday",open:R,onClose:F,onOpen:Y,placeholder:B="Choose Date...",value:V,showInputs:T=!0,...G})=>{let $=(0,l.useMemo)(()=>(0,k.Wc)(V),[V]),W=(0,l.useCallback)(e=>{G.onChange&&(!G.variant&&(0,x.le)(e)||"single"===G.variant&&(0,x.le)(e)||"multi"===G.variant&&(0,x.m)(e)?G.onChange(e):"range"===G.variant&&(0,x.P0)(e)&&G.onChange(e))},[G.variant,G.onChange]),[U,O]=(0,l.useState)($),[K,Q]=(0,l.useState)($),[q,z]=(0,l.useState)(!1),J=(0,l.useCallback)(e=>{Q(e),z(null===e||!(0,x.QJ)(e)||null!==e.to)},[]),[H,L]=(0,l.useState)(null),[X,Z]=(0,l.useState)(()=>(0,k.vV)($)??(0,k.iV)(new Date)),[ee,et]=(0,l.useState)(!0),[ea,en]=(0,l.useState)(void 0),er=o||i,el=(0,l.useMemo)(()=>{if(!M)return;let e=(0,k.iV)(M);return C?(0,k.Uq)(e,"backward"):e},[M,C]),eo=(0,l.useMemo)(()=>{if(!w)return;let e=(0,k.iV)(w);return C?(0,k.Uq)(e,"forward"):e},[w,C]),ei=ee?P:"1-month",[es,eu]=(0,l.useState)(X),ed=(0,l.useCallback)(e=>{Z(t=>{if("1-month"===ei)if(t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear())return t;else return(0,f.X)(e,1);return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()||(0,p.P)(t,1).getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()||(0,p.P)(t,1).getMonth()===e.getMonth()&&0===e.getMonth()&&(0,h.e)(t,1).getFullYear()===e.getFullYear()?t:(0,f.X)(e,1)}),eu(e)},[ei]),ec=G.variant??"single",em="range"===G.variant?G.maxRangeSize:void 0,ef="range"===G.variant?G.minRangeSize:void 0,ep="multi"===G.variant?G.maxSelections:void 0,eh=T&&er,[eg,ey]=(0,l.useState)("range"===ec?"from":null),ev=eh?"to"===eg?"from":"to":eg??"from",eb=(0,l.useRef)(null),eD=()=>setTimeout(()=>eb.current?.focus()),ex=(0,l.useRef)(null),[ek,eC]="string"==typeof t||"function"==typeof t?[ex,t]:[t,null];(0,c.T)(n,ek);let[e_,ej]=(0,l.useState)(R??!1);(0,l.useEffect)(()=>{void 0!==R&&ej(R)},[R]);let eM=(0,l.useCallback)(e=>{d||(void 0===R&&ej(!0),Y?.(e),eD())},[R,Y,d]),ew=(0,l.useCallback)(e=>{void 0===R&&ej(!1),F?.(e)},[R,F]);(0,l.useEffect)(()=>{let e=(0,k.vV)(K,eg);e&&ed(e)},[K,eg,ed]),(0,l.useEffect)(()=>{JSON.stringify($)!==JSON.stringify(K)&&(J($),O($),z(!1))},[$]);let eN=(0,l.useCallback)(e=>{let t=e;eo&&(0,g.Y)(e,eo)?t=eo:el&&(0,y.d)(e,el)&&(t=el),Z((0,k.iV)(t))},[eo,el]),eI=(0,l.useCallback)((e,t)=>{e&&(J(e),O(e)),z(!1),W(e),e_&&ew(t??"submit-click")},[ew,W,J,e_]),eP=(0,l.useCallback)(e=>{eI(e??K)},[eI,K]),eS=(0,l.useCallback)(()=>{J(U??null),z(!1),ey("range"===ec?"from":null),eD()},[U,ec,J]),eA=(0,l.useCallback)(e=>{void 0===ea&&(q&&i?en(e):q&&!er?eI(K):(ew(e),eS()))},[ea,q,i,er,eI,K,ew,eS]),eE=(0,l.useCallback)(e=>{void 0!==ea&&("confirm"===e?eI(K):(ew(ea),eS()),en(void 0))},[ea,eI,ew,eS,K]),eR=(0,l.useCallback)(e=>{let t;switch(ec){case"single":if(!(e instanceof Date))break;t=(0,k.qE)(e,{minDate:eo,maxDate:el});break;case"multi":if(!(0,x.m)(e))break;t=(e??[]).filter(e=>(0,k.Bt)(e,{minDate:eo,maxDate:el})).slice(-(ep??0));break;case"range":if(!(0,x.QJ)(e)||null===e)break;t=S(e,{maxDate:el,minDate:eo,maxRangeSize:em,minRangeSize:ef,adjustableRangeEnd:ev,disableWeekends:C})}t&&(e_?J(t):eI(t))},[el,eo,ec,ep,em,ef,e_,eI,J,ev,C]),eF=(0,l.useCallback)(()=>{J(null),eI(null)},[J,eI]),eY=(0,l.useCallback)((e,t,a=!1,n)=>{if("multi"===ec&&(0,x.m)(K)){let a=[e];if(t.range&&!t.multiple){let t=K?.[K.length-1]||es,n=(0,y.d)(e,t),r=(0,v.f)(t,0),l=n?{start:r,end:e}:{start:e,end:r};a=(0,b.k)(l),n||a.reverse()}let n=t.multiple&&K?[...K]:[];for(let t of a){let a=n.findIndex(e=>(0,D.n)(e,t));a>-1?n.splice(a,1):(0,k.Bt)(e,{minDate:eo,maxDate:el})&&n.push(t)}J(n.slice(-(ep??0)))}else if("range"===ec&&(0,x.QJ)(K)){if(K?.to&&(0,D.n)(K.from,e)){ey("from"),eD();return}if(K?.to&&(0,D.n)(K.to,e)){ey("to"),eD();return}let t=S("to"===eg&&K?{from:K.from,to:e}:{from:e,to:eh?K?.to??null:null},{minDate:eo,maxDate:el,maxRangeSize:em,minRangeSize:ef,disableWeekends:C,adjustableRangeEnd:ev}),n="to"===eg&&K?"from":"to";L(t.to?null:{from:t.from,to:null}),J(t),ey(n),!er&&t.to?eI(t):a||eD()}else J(e),er?a||eD():eI(e,n)},[K,es,J,ep,eo,el,ev,eg,eh,em,ef,C,er,eI,ec]),eB=(0,l.useCallback)(e=>{K&&"range"===ec&&(0,x.QJ)(K)&&H&&!eh&&L(S({from:K.from,to:e},{minDate:eo,maxDate:el,maxRangeSize:em,minRangeSize:ef,adjustableRangeEnd:ev,disableWeekends:C}))},[C,H,el,em,ef,eo,K,ec,eh,ev]);(0,m.w)(([e])=>{if(!e)return;let{width:t}=e.contentRect;et(t>640)});let eV=(0,l.useMemo)(()=>({configuration:{anchor:eC,anchorClassName:a,confirmation:er,confirmUnsavedClose:i,compressedHeader:s,dateFormat:u,disabled:d,disableWeekends:C,fieldName:_,iconPlacement:j,maxDate:el,minDate:eo,placeholder:B,showInputs:eh,showTodayButton:N,showClearButton:I,view:ei,weekStartsOn:A,variant:ec},activeRangeEnd:eg,setActiveRangeEnd:ey,anchorRef:ek,close:eA,confirmingClose:void 0!==ea,currentViewingDate:X,focusDate:es,goToMonth:eN,hoverRange:H,inputRef:eb,isDirty:q,isOpen:e_,onClearSelection:eF,onConfirmClose:eE,onDateHover:eB,onDateInput:eR,onDateSelection:eY,open:eM,saveValue:eP,selection:K,selectionActive:!1,setFocusDate:ed,setHoverRange:L}),[eg,eC,ek,a,eF,eA,s,eE,i,er,ea,X,u,C,d,es,_,eN,eB,H,j,eR,q,e_,el,eo,eM,B,eP,K,eY,ed,I,eh,N,ec,ei,A]);return(0,r.jsx)(E.Provider,{value:eV,children:e})};try{E.displayName||(E.displayName="Context")}catch{}try{F.displayName||(F.displayName="DatePickerProvider")}catch{}let Y=()=>{let{isOpen:e,open:t,close:a}=R();return n=>{"key"in n?[" ","Enter","ArrowDown"].includes(n.key)&&(n.preventDefault(),t("anchor-key-press")):e?a("anchor-click"):t("anchor-click")}};var B=a(49453);let V={calendarIcon:"Anchor-module__calendarIcon--vmzmc"};function T(e){e.current&&e.current.setSelectionRange(0,e.current.value.length,"forward")}var G=a(337),$=a(99511),W=a(26480),U=a(86877),O=a(29255),K=a(34164),Q=a(19684),q=a(7818),z=a(83223),J=a(77396),H=a(11897),L=a(68406),X=a(6146),Z=a(4721),ee=a(26638),et=a(12108),ea=a(50879),en=a(47728),er=a(55375),el=a(12837),eo=a(39804);let ei=()=>{let{configuration:{minDate:e,maxDate:t,disableWeekends:a}}=R();return(n,r)=>{let l=null;switch(r.key){case"ArrowRight":l=(0,v.f)(n,1),a&&(0,Q.c)(l)&&(l=(0,q.u)(l));break;case"ArrowLeft":l=(0,j.e)(n,1),a&&(0,Q.c)(l)&&(l=(0,z.N)(l));break;case"ArrowUp":l=(0,J.k)(n,1);break;case"ArrowDown":l=(0,H.J)(n,1);break;case"Home":l=a?(0,L.p)(n)?n:(0,X._)(n):(0,Z.X)(n)?n:(0,ee.W)(n);break;case"End":l=a?(0,et.C)(n)?n:(0,ea.j)(n):(0,en._)(n)?n:(0,er.R)(n);break;case"PageUp":l=r.shiftKey?(0,el.d)(n,1):(0,eo.a)(n,1);break;case"PageDown":l=r.shiftKey?(0,h.e)(n,1):(0,p.P)(n,1)}return l&&(0,k.iV)((0,k.qE)(l,{minDate:e,maxDate:t}))}};var es=a(90680);let eu=({children:e,id:t})=>(0,r.jsx)("span",{className:"sr-only",id:t,"aria-live":"polite",children:e});try{eu.displayName||(eu.displayName="HiddenDescription")}catch{}let ed={container:"Input-module__container--Xcn7K",rangeInputs:"Input-module__rangeInputs--cCy1G",rangeInputsSeparator:"Input-module__rangeInputsSeparator--zAoYC",singleDateInputContainer:"Input-module__singleDateInputContainer--UkBWU",hasCalendarButton:"Input-module__hasCalendarButton--cBe1A",singleDateInput:"Input-module__singleDateInput--wfBlK",activeRangeEnd:"Input-module__activeRangeEnd--fWov0",FormControl:"Input-module__FormControl--scK8C",fullWidth:"Input-module__fullWidth--scl7k",multiDateInputContainer:"Input-module__multiDateInputContainer--aA3Z1",multiDateInput:"Input-module__multiDateInput--fWUfH",calendarIconButton:"Input-module__calendarIconButton--eV3PF",successIcon:"Input-module__successIcon--2jasV",dangerIcon:"Input-module__dangerIcon--AYHFx"},ec=({status:e})=>"success"===e?(0,r.jsx)(d.A,{icon:i.CheckIcon,className:ed.successIcon}):"error"===e?(0,r.jsx)(d.A,{icon:i.XIcon,className:ed.dangerIcon}):null,em=({value:e,onChange:t,calendarButton:a},n)=>{let o=(0,l.useRef)(null);(0,c.T)(n,o);let{configuration:{dateFormat:i,minDate:s,maxDate:u,disableWeekends:d}}=R(),m=(0,l.useCallback)(e=>e?(0,B.Yq)(e,(0,B.eW)(i)):"",[i]),[f,p]=(0,l.useState)({}),h=()=>p({}),[v,b]=(0,l.useState)(()=>m(e)),D=(0,l.useCallback)(()=>null!==o.current&&document.activeElement===o.current,[o]),x=(0,l.useCallback)(e=>(0,B._U)(e,[i]),[i]);(0,l.useEffect)(()=>{b(t=>D()&&x(t)?.valueOf()===e?.valueOf()?t:m(e))},[e,m,D,x]);let k=(0,l.useCallback)(()=>{v?p({status:"success"}):p({})},[v,p]),C=()=>(0,r.jsx)(ec,{...f}),[_,j]=a?.position==="end"?[C,a.Component]:[a?.Component,C];return{inputProps:{value:v,onChange:({target:e})=>{if(b(e.value),!e.value){p({}),t(null);return}let a=x(e.value);a?s&&(0,g.Y)(a,s)?(p({status:"error",message:es.o.beforeMinDate(s)}),t(null)):u&&(0,y.d)(a,u)?(p({status:"error",message:es.o.afterMaxDate(u)}),t(null)):d&&(0,Q.c)(a)?(p({status:"error",message:es.o.weekend}),t(null)):(p({status:"success"}),t(a)):(p({status:"error"}),t(null))},onFocus:k,onBlur:()=>h(),ref:o,leadingVisual:_,trailingVisual:j,validationStatus:"error"===f.status?"error":void 0,"aria-invalid":"error"===f.status},format:m,resetText:()=>{b(m(e)),h()},inputRef:o,validity:f,isFocused:D}},ef=(0,l.forwardRef)(({value:e,onChange:t,placeholder:a,"aria-label":n,onFocus:o,fullWidth:i,disableShortcuts:s=!1,calendarButton:u,activeRangeEnd:d=!1,className:c,disabled:m},f)=>{let{inputProps:p,resetText:h,inputRef:g,validity:y}=em({value:e,onChange:e=>e&&t(e),calendarButton:u},f),v=(0,l.useRef)(!1);setTimeout(()=>{v.current&&T(g)});let b=ei(),D=(0,l.useId)(),x=(0,l.useId)();return(0,r.jsxs)("div",{className:(0,K.$)(ed.singleDateInputContainer,i&&ed.fullWidth,u&&ed.hasCalendarButton),children:[(0,r.jsx)($.A,{...p,onFocus:e=>{p.onFocus?.(e),s||(v.current=!0),o?.()},onBlur:e=>{v.current=!1,p.onBlur?.(e),h()},onChange:e=>{p.onChange?.(e),v.current=!1},onKeyDown:a=>{if(a.defaultPrevented||!v.current||!e)return;let n=b(e,a);n&&(a.preventDefault(),t(n),h())},onMouseDown:()=>v.current=!1,onMouseUp:()=>{v.current&&T(g)},size:"small",placeholder:a,"aria-label":n,"aria-describedby":D,"aria-errormessage":x,ref:g,className:(0,K.$)(ed.singleDateInput,d&&ed.activeRangeEnd,c),disabled:m}),(0,r.jsx)(G.n,{id:x,message:y.message,position:"above"}),(0,r.jsx)(eu,{id:D,children:s?es.o.dateInputDescription:es.o.shortcutInputDescription})]})});ef.displayName="SingleDateInput";let ep=(0,l.forwardRef)(({value:e,onChange:t,fullWidth:a,onDateClick:n,calendarButton:o,isAnchor:i,className:s,disabled:u},d)=>{let[c,m]=(0,l.useState)(null),f=()=>{m(null),g()},{inputProps:p,format:h,resetText:g,validity:y}=em({value:c,onChange:m,calendarButton:o},d),v=(0,l.useMemo)(()=>e.map(e=>({id:e.valueOf(),text:h(e),onClick:()=>n(e)})),[e,h,n]),b=(0,l.useId)(),x=(0,l.useId)(),k=(0,r.jsx)(W.A,{...p,tokens:v,onTokenRemove:a=>{t(e.filter(e=>e.valueOf()!==a))},onKeyDown:a=>{"Enter"===a.key&&c&&(a.preventDefault(),c&&(t(e.filter(e=>!(0,D.n)(e,c)).concat(c)),f()))},onBlur:e=>{p.onBlur?.(e),f()},className:(0,K.$)(ed.multiDateInput,s),size:"medium","aria-describedby":b,"aria-errormessage":i?x:void 0,disabled:u});return i?(0,r.jsxs)("div",{className:(0,K.$)(ed.multiDateInputContainer,ed.fullWidth),children:[k,(0,r.jsx)(G.n,{message:y.message,id:x}),(0,r.jsx)(eu,{id:b,children:es.o.dateInputDescription})]}):(0,r.jsxs)(U.A,{className:(0,K.$)(ed.FormControl,a&&ed.fullWidth),children:[(0,r.jsx)(U.A.Label,{visuallyHidden:!0,children:"Selected Dates"}),c&&"success"===y.status?(0,r.jsxs)(U.A.Validation,{variant:"success","aria-live":"polite",children:["Press ",(0,r.jsx)(O.U,{keys:"enter",format:"condensed"})," to add ",h(c),"."]}):"error"===y.status&&y.message?(0,r.jsx)(U.A.Validation,{variant:"error","aria-live":"polite",children:y.message}):(0,r.jsxs)(U.A.Caption,{"aria-live":"polite",children:["Hold ",(0,r.jsx)(O.U,{keys:"Mod",format:"condensed"})," to click multiple dates."]}),k,(0,r.jsx)(eu,{id:b,children:es.o.dateInputDescription})]})});ep.displayName="MultiDateInput";let eh=({onAction:e})=>(0,r.jsx)(s.K,{variant:"invisible",icon:i.CalendarIcon,"aria-label":"Open date picker",type:"button",onClick:e,onKeyDown:e,size:"small",className:ed.calendarIconButton}),eg=(0,l.forwardRef)(({fullWidth:e,anchorRef:t,className:a,disabled:n},o)=>{let{selection:i,onDateInput:s,activeRangeEnd:u,setActiveRangeEnd:d,setFocusDate:c,configuration:{variant:m,iconPlacement:f}}=R(),p=void 0!==t,h=(0,l.useRef)(null),g=(0,l.useRef)(null);(0,l.useImperativeHandle)(o,()=>({focus:()=>"to"===u?g.current?.focus():h.current?.focus()}));let y=Y(),v=(0,l.useMemo)(()=>p&&"none"!==f?{Component:()=>(0,r.jsx)(eh,{onAction:y}),position:f}:void 0,[f,p,y]),b=(0,l.useMemo)(()=>p&&"none"!==f?{Component:()=>(0,r.jsx)(eh,{onAction:e=>{d("to"),y(e)}}),position:f}:void 0,[f,p,y,d]),D=(0,x.QJ)(i)&&"range"===m?(0,r.jsxs)("div",{ref:t,className:ed.rangeInputs,children:[(0,r.jsx)(ef,{"aria-label":"Start date",ref:h,value:i?.from??null,onChange:e=>s({from:e,to:i?.to??null}),onFocus:()=>d("from"),fullWidth:e,disableShortcuts:p,activeRangeEnd:!p&&"from"===u,calendarButton:v,className:a,disabled:n}),(0,r.jsx)("span",{className:ed.rangeInputsSeparator,children:" - "}),(0,r.jsx)(ef,{"aria-label":"End date",ref:g,value:i?.to??null,onChange:e=>s({from:i?.from??e,to:e}),onFocus:()=>d("to"),fullWidth:e,disableShortcuts:p,activeRangeEnd:!p&&"to"===u,calendarButton:b,className:a,disabled:n})]}):(0,x.le)(i)&&"single"===m?(0,r.jsx)(ef,{"aria-label":p?void 0:"Selected date",ref:t??h,value:i,onChange:s,fullWidth:e,disableShortcuts:p,calendarButton:v,className:a,disabled:n}):(0,x.m)(i)&&"multi"===m?(0,r.jsx)(ep,{"aria-label":p?void 0:"Selected dates",ref:t??h,value:i??[],onChange:s,onDateClick:c,fullWidth:e,isAnchor:p,calendarButton:v,className:a,disabled:n}):null;return p?D:(0,r.jsx)("div",{className:ed.container,children:D})});eg.displayName="DatePickerTextInput";try{ec.displayName||(ec.displayName="ValidityIndicator")}catch{}try{(n=ValidIcon).displayName||(n.displayName="ValidIcon")}catch{}try{eh.displayName||(eh.displayName="CalendarIconButton")}catch{}let ey=(0,l.forwardRef)(({render:e,children:t},a)=>{let n=Y(),{configuration:{disabled:r}}=R();return e({ref:a,"aria-haspopup":"true",tabIndex:0,onClick:n,onKeyDown:n,children:t,disabled:r,"aria-disabled":r})});ey.displayName="ExternalDatePickerAnchor";let ev=()=>(0,r.jsx)(d.A,{icon:i.CalendarIcon,className:V.calendarIcon}),eb=(0,l.forwardRef)(({anchorVariant:e,children:t},a)=>{let{configuration:{iconPlacement:n,anchorClassName:d,fieldName:c,disabled:m},selection:f}=R(),p=Y(),h=(0,l.useMemo)(()=>Array.isArray(f)?f.length>0:!!f,[f])?`${c} - Open date picker (currently selected: ${t})`:`${c} - Choose date...`;return"input"===e?(0,r.jsx)(eg,{anchorRef:a,fullWidth:!0,className:d,disabled:m}):"icon-only"===e?(0,r.jsx)(s.K,{onClick:p,onKeyDown:p,type:"button",className:d,...(0,o.G)("anchor-button"),icon:i.CalendarIcon,ref:a,disabled:m,"aria-label":h}):(0,r.jsx)(u.Q,{"aria-label":h,onClick:p,onKeyDown:p,type:"button",className:d,...(0,o.G)("anchor-button"),ref:a,disabled:m,leadingVisual:"start"===n?ev:void 0,trailingVisual:"end"===n?ev:void 0,children:t})});eb.displayName="DefaultDatePickerAnchor";let eD=()=>{let{configuration:{anchor:e,placeholder:t,variant:a,dateFormat:n},anchorRef:o,selection:i}=R(),s=(0,l.useMemo)(()=>(0,B.gb)({selection:i,dateFormat:n,placeholder:t,rawFormat:!1,variant:a}),[t,a,n,i]);return null===e?null:"function"==typeof e?(0,r.jsx)(ey,{render:e,ref:o,children:s}):(0,r.jsx)(eb,{anchorVariant:e,ref:o,children:s})};try{ev.displayName||(ev.displayName="StyledCalendarIcon")}catch{}var ex=a(24990);let ek={labelText:"ConfirmCloseDialog-module__labelText--VRdFV"},eC=()=>{let{onConfirmClose:e,confirmingClose:t}=R(),a=(0,l.useCallback)(t=>{e("confirm"===t?"confirm":"discard")},[e]);return t?(0,r.jsx)(ex.K,{title:"Save Changes?",confirmButtonContent:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.CheckIcon,{}),(0,r.jsx)("span",{className:ek.labelText,children:"Save"})]}),cancelButtonContent:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.TrashIcon,{}),(0,r.jsx)("span",{className:ek.labelText,children:"Discard"})]}),onClose:a,children:"You have unsaved changes, would you like to save them?"}):null};try{eC.displayName||(eC.displayName="DatePickerConfirmCloseDialog")}catch{}var e_=a(31604),ej=a(18651),eM=a(83494),ew=a(11683),eN=a(45800),eI=a(72471),eP=a(40961),eS=a(92528),eA=a(72483),eE=a(14051),eR=a(93724),eF=a(80874),eY=a(26320);let eB={day:"Day-module__day--Lk_yW",selected:"Day-module__selected--qMeWD",today:"Day-module__today--ATWu5",date:"Day-module__date--ASCWF",rangeFrom:"Day-module__rangeFrom--aiIAc",rangeTo:"Day-module__rangeTo--T4srd",activeRangeEnd:"Day-module__activeRangeEnd--An_E2",rangeMiddle:"Day-module__rangeMiddle--c6Wld",range:"Day-module__range--xx5j9",header:"Day-module__header--EmCNc"},eV=({date:e})=>{let{configuration:{disableWeekends:t,minDate:a,maxDate:n,variant:i,showInputs:s},hoverRange:u,selection:d,onDateHover:c,onDateSelection:m,activeRangeEnd:f}=R(),p=(0,eY.c)(e),h=(0,l.useMemo)(()=>{switch(!0){case!d:return!1;case(0,x.m)(d):return d.some(t=>(0,D.n)(t,e));case(0,x.QJ)(d):return A(e,d)??!1;default:return(0,D.n)(e,d)}},[e,d]),v=(0,l.useMemo)(()=>u?A(e,u)??!1:h,[e,u,h]),b=(0,l.useMemo)(()=>!!a&&(0,g.Y)(e,a)||!!n&&(0,y.d)(e,n)||!!t&&(0,Q.c)(e),[e,a,n,t]),k=(0,l.useCallback)(e=>{s&&e.preventDefault()},[s]),C=(0,l.useCallback)(t=>{if(b)return;if(t instanceof eM.ky)return void m(e,{multiple:!0,range:!1},!0,"submit-key-press");let a={range:t.shiftKey,multiple:(0,ej.U0)()?t.metaKey:t.ctrlKey};"key"in t?[" ","Enter"].includes(t.key)&&(m(e,a,!0,"submit-key-press"),t.preventDefault(),t.stopPropagation()):m(e,a)},[b,m,e]),_=(0,l.useMemo)(()=>{let t=p?" (Today)":"",r="from"===h?" (Start of selected range)":"to"===h?" (End of selected range)":"middle"===h?" (Inside selected range)":"",l=a&&(0,D.n)(e,a)?" (Minimum allowed date)":n&&(0,D.n)(e,n)?" (Maximum allowed date)":"";return`${(0,eI.GP)(e,"EEEE, MMMM d")}${t}${l}${r}`},[p,e,h,a,n]);return(0,r.jsx)(eM.tL,{commands:{"github:select-multiple":()=>m(e,{multiple:!0,range:!1},!0,"submit-key-press")},children:(0,r.jsx)("div",{"aria-disabled":b,"aria-selected":!1!==h,"aria-label":_,"data-date":(0,eI.GP)(e,"MM/dd/yyyy"),"data-disabled":b?"true":void 0,...(0,o.G)(`day-${(0,eI.GP)(e,"MM/dd/yyyy")}`),onClick:C,onMouseDown:k,onKeyDown:C,onMouseEnter:()=>c(e),role:"gridcell",tabIndex:-1,className:(0,K.$)(eB.day,{[eB.today]:p,[eB.selected]:!!v,[eB.range]:"range"===i,[eB.activeRangeEnd]:v===f,[eB.rangeFrom]:"from"===v,[eB.rangeMiddle]:"middle"===v,[eB.rangeTo]:"to"===v}),children:(0,r.jsx)("span",{className:eB.date,children:e.getDate()})})})},eT=()=>(0,r.jsx)("div",{role:"gridcell",className:eB.day}),eG=({date:e})=>(0,r.jsx)("div",{role:"columnheader",className:(0,K.$)(eB.day,eB.header),"aria-label":(0,eI.GP)(e,"EEEE"),...(0,o.G)("weekday-header"),children:(0,eI.GP)(e,"EEEEEE")});try{eV.displayName||(eV.displayName="Day")}catch{}try{eT.displayName||(eT.displayName="BlankDay")}catch{}try{eG.displayName||(eG.displayName="WeekdayHeaderDay")}catch{}let e$={container:"Month-module__container--z5U_x",row:"Month-module__row--vNOCW",title:"Month-module__title--dDTE5",compressedHeader:"Month-module__compressedHeader--gqq2V"},eW={Sunday:0,Monday:1,Tuesday:2,Wednesday:3,Thursday:4,Friday:5,Saturday:6},eU=({date:e,"aria-describedby":t})=>{let{configuration:{weekStartsOn:a,compressedHeader:n,variant:i}}=R(),s=(0,l.useMemo)(()=>(0,eI.GP)(e,"MMMM yyyy"),[e]),u=(0,l.useMemo)(()=>{let t=new Date(e),n={weekStartsOn:eW[a]};return(0,b.k)({start:(0,eS.k)(t,n),end:(0,eA.$)(t,n)}).map(e=>(0,r.jsx)(eG,{date:e},`weekday-${e.toISOString()}-header`))},[a,e]),d=(0,l.useMemo)(()=>{let t=[],n=new Date(e.getFullYear(),e.getMonth(),1),l=(n.getDay()+(7-eW[a]))%7;for(let e=0;eo;e--)t.push((0,r.jsx)(eT,{},`month-post-blank-${e}`));return(0,eF.A)(t,7).map((e,t)=>(0,r.jsx)("div",{className:e$.row,role:"row","aria-label":`Week ${t+1}`,children:e},`month-week-${t}`))},[a,e]),c=(0,l.useId)();return(0,r.jsxs)("div",{className:e$.container,"aria-labelledby":c,"aria-describedby":t,role:"dialog",...(0,o.G)("month"),children:[(0,r.jsx)("span",{className:(0,K.$)(e$.title,n&&e$.compressedHeader),"aria-live":"polite",id:c,children:s}),(0,r.jsxs)("div",{role:"grid","aria-multiselectable":"multi"===i,children:[(0,r.jsx)("div",{className:e$.row,role:"row","aria-hidden":!0,children:u}),d]})]})};try{eU.displayName||(eU.displayName="Month")}catch{}let eO={container:"Panel-module__container--QM8qh",topNav:"Panel-module__topNav--GYQdx",months:"Panel-module__months--VU5D4",footer:"Panel-module__footer--szPNP",footerRow:"Panel-module__footerRow--oTYAd",footerButtons:"Panel-module__footerButtons--Fdy64",arrowButton:"Panel-module__arrowButton--pKXOQ",icon:"Panel-module__icon--ozRZ6",pickers:"Panel-module__pickers--UAT_P",picker:"Panel-module__picker--Bd4ir",option:"Panel-module__option--RRz4t"},eK=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],eQ=(e,t)=>e.current?.querySelector(`[data-date="${(0,eI.GP)(t,"MM/dd/yyyy")}"]`)??void 0,eq=()=>{let{configuration:{minDate:e,maxDate:t,confirmation:a,view:n,showTodayButton:s,showClearButton:c,compressedHeader:m,showInputs:f,variant:h},isDirty:v,saveValue:b,currentViewingDate:D,goToMonth:x,onClearSelection:C,onDateHover:_,setFocusDate:j,inputRef:M,focusDate:w,activeRangeEnd:N}=R(),I=(0,l.useRef)(null),P=(0,l.useRef)(null),S=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(S.current){let e=eQ(I,w);e&&e.focus(),S.current=!1}},[w]);let A=ei(),E=(0,l.useCallback)((e,t,a)=>{let n=t?.getAttribute("data-date"),r=(0,k.iV)(n?new Date(n):new Date),l=A(r,a)??r;return _(l),(0,eP.flushSync)(()=>j(l)),eQ(I,l)},[A,_,j]);(0,eN.G)({containerRef:P,bindKeys:ew.z0.ArrowAll|ew.z0.HomeAndEnd|ew.z0.PageUpDown,focusInStrategy:()=>eQ(I,w)??I.current?.querySelector('[data-date][aria-disabled="false"]')??void 0,getNextFocusable:E},[E,w]);let F=(0,l.useMemo)(()=>{if(!e)return!1;let t=(0,eo.a)(D,1);return e.getFullYear()>=t.getFullYear()&&e.getMonth()>t.getMonth()},[e,D]),Y=(0,l.useMemo)(()=>{if(!t)return!1;let e=(0,p.P)(D,"2-month"===n?2:1);return t.getFullYear()<=e.getFullYear()&&t.getMonth(){if(!s)return!1;let a=(0,k.iV)(new Date);return!(e&&(0,y.d)(e,a)||t&&(0,g.Y)(t,a))},[t,e,s]),V=(0,l.useMemo)(()=>D.getMonth(),[D]),T=(0,l.useMemo)(()=>D.getFullYear(),[D]),G=(0,l.useCallback)(e=>{let t=parseInt(e.currentTarget.value,10);"picker-header-year"===e.currentTarget.id?x(new Date(t,V)):x(new Date(T,t))},[V,T,x]),$=(0,l.useMemo)(()=>{let a=eK,n=[];for(let l of(e&&T===e.getFullYear()&&(a=a.filter(t=>eK.indexOf(t)>=e.getMonth())),t&&T===t.getFullYear()&&(a=a.filter(e=>eK.indexOf(e)<=t.getMonth())),a))n.push((0,r.jsx)("option",{className:eO.option,value:eK.indexOf(l),children:l},l));return(0,r.jsx)("select",{id:"picker-header-month",onChange:G,className:eO.picker,value:V,"aria-label":"Go to month",children:n})},[e,t,V,T,G]),W=(0,l.useMemo)(()=>{let a=[],n=(0,k.iV)(new Date).getFullYear(),l=e?e.getFullYear():n-200,o=t?t.getFullYear():n+200;for(let e=l;e<=o;e++)a.push((0,r.jsx)("option",{className:eO.option,value:e,children:e},e));return(0,r.jsx)("select",{className:eO.picker,id:"picker-header-year",onChange:G,value:T,"aria-label":"Go to year",children:a})},[e,t,T,G]),U=(0,l.useMemo)(()=>"2-month"===n?(0,p.P)(D,1):null,[n,D]),O=c||B||a,K=(0,l.useCallback)(()=>{let e=(0,k.iV)(new Date);S.current=!0,j(e)},[j]),Q=(0,l.useCallback)(()=>{C()},[C]),q=(0,l.useId)(),z="single"===h?es.o.monthSingleDescription:"multi"===h?es.o.monthMultiDescription((0,ej.U0)()):"range"===h&&null!==N?es.o.monthRangeDescription[N]:"";return(0,r.jsxs)(eM.tL,{as:"div",commands:{"github:submit-form":()=>{v&&b()}},className:eO.container,ref:I,...(0,o.G)("datepicker-panel"),children:[(0,r.jsxs)("header",{className:eO.topNav,children:[m&&(0,r.jsxs)("div",{...(0,o.G)("datepicker-compressed-header"),className:eO.pickers,children:[$,W]}),(0,r.jsx)(u.Q,{size:"small",className:eO.arrowButton,onClick:()=>x((0,eo.a)(D,1)),disabled:F,"aria-label":"Go to previous month",...(0,o.G)("previous-button"),children:(0,r.jsx)(d.A,{icon:i.ChevronLeftIcon,className:eO.icon})}),(0,r.jsx)(u.Q,{size:"small",className:eO.arrowButton,onClick:()=>x((0,p.P)(D,1)),disabled:Y,"aria-label":"Go to next month",...(0,o.G)("next-button"),children:(0,r.jsx)(d.A,{icon:i.ChevronRightIcon,className:eO.icon})})]}),(0,r.jsxs)("div",{className:eO.months,ref:P,children:[(0,r.jsx)(eu,{id:q,children:z}),(0,r.jsx)(eU,{date:D,"aria-describedby":q}),U&&(0,r.jsx)(eU,{date:U,"aria-describedby":q})]}),(O||f)&&(0,r.jsxs)("footer",{className:eO.footer,children:[("1-month"===n||!O||"multi"===h)&&f&&(0,r.jsx)("div",{className:eO.footerRow,children:(0,r.jsx)(eg,{ref:M,fullWidth:!0})}),O&&(0,r.jsxs)("div",{className:eO.footerRow,children:[(0,r.jsxs)("div",{className:eO.footerButtons,children:[c&&(0,r.jsx)(u.Q,{variant:"invisible",size:"small",onClick:Q,"aria-label":"Clear selected date",disabled:!D,children:"Clear"}),B&&(0,r.jsx)(u.Q,{variant:"invisible",size:"small",onClick:K,"aria-label":"Go to today's date",disabled:D.getFullYear()===new Date().getFullYear()&&D.getMonth()===new Date().getMonth(),children:"Today"})]}),"2-month"===n&&f&&"multi"!==h&&(0,r.jsx)(eg,{ref:M}),a&&(0,r.jsx)(eM.cQ,{variant:"primary",size:"small",disabled:!v,commandId:"github:submit-form","aria-label":"Apply selection and close",type:"submit",...(0,o.G)("datepicker-apply"),children:"Apply"})]})]})]})};try{eq.displayName||(eq.displayName="DatePickerPanel")}catch{}let ez=e=>{let{isOpen:t,close:a,open:n,anchorRef:l}=R();return(0,r.jsx)(e_.T,{focusTrapSettings:{restoreFocusOnCleanUp:!0},focusZoneSettings:{disabled:!0},open:t,onClose:a,onOpen:n,renderAnchor:null,anchorRef:l,overlayProps:{"aria-label":"Date Picker",role:"dialog","aria-modal":"true"},...e,children:(0,r.jsx)(eq,{})})};try{ez.displayName||(ez.displayName="DatePickerOverlay")}catch{}let eJ=(0,l.forwardRef)(({anchoredOverlayProps:e,configuration:t,...a},n)=>{let l={...t,...a};return(0,r.jsxs)(F,{...l,forwardedAnchorRef:n,children:[(0,r.jsx)(eC,{}),(0,r.jsx)(eD,{}),(0,r.jsx)(ez,{...e})]})});eJ.displayName="DatePicker"},90680:(e,t,a)=>{a.d(t,{o:()=>r});var n=a(72471);let r={invalidConfiguration:"Invalid configuration",invalidDate:"Invalid date",invalidSelection:"Invalid selection",weekend:"Must not fall on a weekend",beforeMinDate:e=>`Must be on or after ${(0,n.GP)(e,"PP")}`,afterMaxDate:e=>`Must be on or before ${(0,n.GP)(e,"PP")}`,shortcutInputDescription:'Use arrow keys to select a date, or type a date like "Dec 28, 2020" or "12/28/2020".',dateInputDescription:'Type a date, like "Dec 28, 2020" or "12/28/2020".',monthSingleDescription:"Select a date from the grid.",monthMultiDescription:e=>`Select dates from the grid. Use ${e?"command":"control"} + enter to select multiple, and shift + enter to select ranges.`,monthRangeDescription:{from:"Select a start date from the grid.",to:"Select an end date from the grid."}}}}]); //# sourceMappingURL=packages_date-picker_components_DatePicker_tsx-611ad653b84f.js.map